package kt_sort

class Solution {

    fun insertSort(arr: Array<Int>) {
        for(i in 1 until arr.size) {
            val key = arr[i]
            var j = i - 1
            while(j >= 0 && arr[j] > key) {
                arr[j + 1] = arr[j]
                j--
            }
            arr[j + 1] = key
        }
    }

    fun

}

fun main() {
    val arr = arrayOf(3,1,2,4,5,6,9,8,4,7)
    val s = Solution()
    s.insertSort(arr)
    println(arr.contentToString())
}
